//
// Created by 匡涂上青 on 2021/8/8.
//

#ifndef KGL_FPSCAMERA_H
#define KGL_FPSCAMERA_H

#include "kgl.h"

#include "scriptable.h"

class FPSCamera : public Scriptable {
public:
    FPSCamera(kgl::Ref<kgl::Transform> camera_transform, kgl::Ref<kgl::PerspectiveCamera> camera);

    void OnSetup() override;

    void OnUpdate() override;

    void OnDestroy() override;

    kgl::Ref<kgl::PerspectiveCamera> get_camera() const {
        return this->camera;
    }

    float moveSpeed = 0.5f;

private:

    glm::vec3 get_front() const;

    glm::vec3 get_right() const;

    glm::vec3 get_up() const;

private:
    kgl::Ref<kgl::Transform> trans_ca;
    kgl::Ref<kgl::PerspectiveCamera> camera;
    float pitch, yaw;
    glm::vec2 last_cursor_pos;

};

#endif //KGL_FPSCAMERA_H
